<?php
require("../inc/common.inc.php");
$web_title="会员登录";
@header('Content-Type:text/html;charset= utf-8');
if($actions=="check"){
	$name=$mobile;
	$pwd=$password;

	if($name==""){
		$fun->popmassage("用户名为空","Login.php","popgotourl");
		exit();
	}
	if($pwd==""){
		$fun->popmassage("密码为空","Login.php","popgotourl");
		exit();
	}

	$pwd=md5($pwd);
	///判断用户名和密码是否正确
	$usernum=$db->excu("SELECT * FROM mx_app_user WHERE username='$name' and password='$pwd' ");
	if($db->num_rows($usernum)!=1){
		$fun->popmassage("密码或手机号不正确","Login.php","popgotourl");
		exit();
	}else{
		$usernum=$db->fetch_array($usernum);
			
		if ($usernum["username"]!=trim($name) or $usernum["password"]!=trim($pwd)){
			$fun->popmassage("密码或手机号不正确","Login.php","popgotourl");
			exit();
		}
		if ($usernum["isok"]==0){
			$fun->popmassage("此手机号已经被禁用","Login.php","popgotourl");
			exit();
		}
		if(!$usernum['vppuserid'] && $vpp_user_info['id']){
			$db->exe_update('mx_app_user', array('vppuserid'=>$vpp_user_info['id']),"id=".$usernum['id']);
		}
		$usernum['nickname'] = $usernum['nicheng'];
		if (trim($usernum["nickname"])==""){$usernum["nickname"]=$usernum["username"];}
		$info = $usernum;
		$time = time()+3600*24*30;
		setcookie('userid',$info["id"],$time,'/');
		setcookie('username',$info["username"],$time,'/');
		setcookie('password',$info["password"],$time,'/');
		setcookie('nickname',$info["nickname"],$time,'/');
		setcookie('LastLoginTime',$info["lastlogintime"],$time,'/');
			
		////写入登陆日志
		$ip=$_SERVER['REMOTE_ADDR'];
		$date=date("Y-m-d H:i:s");
		// 		$sql="insert into mx_shanghu_log (suid,sname,times,ip) values ('$usernum[id]','$name','$date','$ip')";
		// 		$db->excu($sql);
		$vppuserStr = '';
		if($vpp_user_info['id']){
			$vppuserStr = "vppuserid=".$vpp_user_info['id'].",";
		}
		//修改登陆信息
		$sql="update mx_app_user set $vppuserStr lastloginiP='$ip',lastlogintime='$date'  where username='$name' and password='$pwd'";
		$db->excu($sql);
		echo "<script>location.href='/user/index.php';</script>";
	}
	exit();
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1" name="viewport">
<title><?php echo $web_title;?></title>
<meta content="application/xhtml+xml;charset=UTF-8" http-equiv="Content-Type">
<meta content="no-cache,must-revalidate" http-equiv="Cache-Control">
<meta content="no-cache" http-equiv="pragma">
<meta content="0" http-equiv="expires">
<meta content="telephone=no, address=no" name="format-detection">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<meta name="apple-mobile-web-app-capable" content="yes" /> <!-- apple devices fullscreen -->
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
</head>
<body>
<?php require("../w_head.php")?>

<div class="zuce_t">会员登陆</div>

<div class="zuce_c">	
	 
<form name="userform2" id="userform2" action="Login.php?actions=check" method="post" onsubmit="return checkuser2()">
 <ul> 
  <li>手机号：</li>
   <li> <input type="text" name="mobile" size="13" class="input1" /></li>
  <li>密 &nbsp;&nbsp;码：</li>
  <li><input type="password" name="password" size="13"  class="input1"></li>
 </ul>
 <dt style="margin-top:20px;"><a href="javascript:void(0)" onclick="$('#userform2').submit();" class="submit" id="showcard1" style="color:#ffffff">登录</a></dt>
 </form>
 <p><!-- <a href="/user/getpassword.php">忘记密码</a> -->    没有帐号?<a href="/user/regist.php">立即注册</a>  </p>
</div>

<script>
function checkuser2(){
    if (document.userform2.mobile.value==""){
	    alert('手机号不能为空');
		document.userform2.mobile.focus();
		return false;
	}
    if (document.userform2.password.value==""){
	    alert('密码不能为空');
		document.userform2.password.focus();
		return false;
	}
}
</script>  
	
	
<div class="clear"></div>
<?php require("../w_foot.php")?>